<template>
 <view>
   <view class="size">
		{{title}}
		</view>

		<u-message-input :focus="true" :maxlength="6" ref="password" :dot-fill="true" class="fill" @finish="finish" ></u-message-input>
        <u-toast ref="uToast" />
 </view>
</template>

<script>
	import {mapState,mapMutations,mapActions} from 'vuex'
 export default {
   data () {
     return {
       title:'请输入旧的交易密码',
       
     }
   },
   components: {

   },
   methods: {
       ...mapMutations({
        changeOldPassword:'PERSONAL/CHANGE_OLD_PASSWORD',//旧密码
        changeNewPassword:'PERSONAL/CHANGE_NEW_PASSWORD',//新密码
       }),
       ...mapActions({
        changeConfirmPassword:'PERSONAL/CHANGE_CONFIRM_PASSWORD',//确认密码提交
       }),
    finish(e){
     if(this.title=='请输入旧的交易密码'){
      this.changeOldPassword(e)
      this.title="请输入新的交易密码"
    this.$refs.password.valueModel=""
     }else if(this.title=='请输入新的交易密码'){
       this.changeNewPassword(e)
       this.title="请再次输入新的交易密码"
        this.$refs.password.valueModel=""
     }else{
          this.$refs.password.valueModel="" 
           this.title="请输入旧的交易密码" 
           if(this.transaction.new_pwd!=e){
            this.$refs.uToast.show({
					title: '两次密码不一致',
				})
                return
           }
           this.changeConfirmPassword(e) 
     }
    }
   },
   mounted() {

   },
   watch: {

   },
   computed: {
   ...mapState({
       transaction:(state)=>state.PERSONAL.transaction
   })
   }
 }
</script>

<style scoped lang='scss'>
	.size {
		margin-left: 32rpx;
		margin-top: 32rpx;
	}

	.fill {
		margin-top: 68rpx;
	}
</style>
<style>
	page {
		background: #FAFAFA;
	}
</style>